﻿$(document).ready(function() {
    $('li.mainlevel').mousemove(function() { $(this).find('ul').slideDown(400); });
    $('li.mainlevel').mouseleave(function() { $(this).find('ul').slideUp(100); });

    $('.movieUL li').hover(function() { $(this).addClass('bk') }, function() { $(this).removeClass('bk') });

    var param = urlParam();
    var type = param.type;
    if (type) {
        $('#menu' + type).addClass('currentMenu');
    }
});


window.onunload = beforUnload;
function beforUnload() {
    //var t = $("#t").val();
    var tj = $("#tj").val();
    var d = new Date();
    var e = d.toLocaleString();
    $.get("/service/v.ashx", {tj: tj, tje:e});//t: t, 
}

function urlParam(){ 
    var args = {}; 
    var query = location.search.substring(1); 
    var pairs = query.split('&'); 
    for(var i = 0; i < pairs.length; i++){ 
        var pos = pairs[i].indexOf('='); 
        if(pos == -1) continue; 
        var name = pairs[i].substring(0,pos); 
        var value = pairs[i].substring(pos + 1); 
        value = decodeURIComponent(value); 
        args[name] = value; 
    } 
    return args; 
}

//function initRound() {
//    var bf = '<b class="rctop"><b class="rc1"></b>' +
//	            '<b class="rc2"></b><b class="rc3"></b><b class="rc4"></b></b>';
//    var af = '<b class="rcbottom"><b class="rc4"></b><b class="rc3"></b>' +
//                '<b class="rc2"></b><b class="rc1"></b></b>';

//    $('.roundedCommon').each(function () {
//        var c = $(this).attr('color');
//       
//        $(this).prepend(bf).append(af);
//        $(this).addClass('round' + c);
//    });
//}

function getBF(color) {
    var bf = '<b class="rctop corner' + color + '"><b class="rc1 area' + color + '"></b>' +
	            '<b class="rc2 area' + color + '"></b><b class="rc3 area' + color + '"></b><b class="rc4 area' + color + '"></b></b>';
    return bf;
}
function getAF(color) {
    var af = '<b class="rcbottom corner' + color + '"><b class="rc4 area' + color + '"></b><b class="rc3 area' + color + '"></b>' +
                '<b class="rc2 area' + color + '"></b><b class="rc1 area' + color + '"></b></b>';
    return af;
}

var OriginImage = new Image();
function GetImgWidth(oImage) {
    if (OriginImage.src != oImage.src) OriginImage.src = oImage.src;
    return OriginImage.width;
}
function GetImgHeight(oImage) {
    if (OriginImage.src != oImage.src) OriginImage.src = oImage.src;
    return OriginImage.height;
}

function resizeMovieImg(obj, maxW, maxH){    
    var img = $(obj)[0];
    var imgH = GetImgHeight(img); var imgW = GetImgWidth(img);
    var ratioH = imgH / maxH; var ratioW = imgW / maxW;
    var showH = 0, showW = 0;
    if (ratioH <= 1 && ratioW <= 1) {  
        showH = imgH;
        showW = imgW;
    } else {
        if (ratioH > ratioW) {
            showH = imgH / ratioH;
            showW = imgW / ratioH;
        } else if (ratioH < ratioW) {
            showH = imgH / ratioW;
            showW = imgW / ratioW;
        } else {
            showH = imgH / ratioH;
            showW = imgW / ratioH;
        }
    }
    
    $(obj).css("height", showH + "px");
    $(obj).css("width", showW + "px");
}
